{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# BikeSharing线性回归分析"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1.导入工具包"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "from sklearn.metrics import mean_squared_error\n",
    "from sklearn.metrics import r2_score\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 2.读取数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>instant</th>\n",
       "      <th>season_1</th>\n",
       "      <th>season_2</th>\n",
       "      <th>season_3</th>\n",
       "      <th>season_4</th>\n",
       "      <th>mnth_1</th>\n",
       "      <th>mnth_2</th>\n",
       "      <th>mnth_3</th>\n",
       "      <th>mnth_4</th>\n",
       "      <th>mnth_5</th>\n",
       "      <th>...</th>\n",
       "      <th>weekday_5</th>\n",
       "      <th>weekday_6</th>\n",
       "      <th>temp</th>\n",
       "      <th>atemp</th>\n",
       "      <th>hum</th>\n",
       "      <th>windspeed</th>\n",
       "      <th>cnt</th>\n",
       "      <th>holiday</th>\n",
       "      <th>workingday</th>\n",
       "      <th>yr</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.355170</td>\n",
       "      <td>0.373517</td>\n",
       "      <td>0.828620</td>\n",
       "      <td>0.284606</td>\n",
       "      <td>0.110792</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.379232</td>\n",
       "      <td>0.360541</td>\n",
       "      <td>0.715771</td>\n",
       "      <td>0.466215</td>\n",
       "      <td>0.089623</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.171000</td>\n",
       "      <td>0.144830</td>\n",
       "      <td>0.449638</td>\n",
       "      <td>0.465740</td>\n",
       "      <td>0.152669</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.175530</td>\n",
       "      <td>0.174649</td>\n",
       "      <td>0.607131</td>\n",
       "      <td>0.284297</td>\n",
       "      <td>0.177174</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.209120</td>\n",
       "      <td>0.197158</td>\n",
       "      <td>0.449313</td>\n",
       "      <td>0.339143</td>\n",
       "      <td>0.181546</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 35 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   instant  season_1  season_2  season_3  season_4  mnth_1  mnth_2  mnth_3  \\\n",
       "0        1         1         0         0         0       1       0       0   \n",
       "1        2         1         0         0         0       1       0       0   \n",
       "2        3         1         0         0         0       1       0       0   \n",
       "3        4         1         0         0         0       1       0       0   \n",
       "4        5         1         0         0         0       1       0       0   \n",
       "\n",
       "   mnth_4  mnth_5 ...  weekday_5  weekday_6      temp     atemp       hum  \\\n",
       "0       0       0 ...          0          1  0.355170  0.373517  0.828620   \n",
       "1       0       0 ...          0          0  0.379232  0.360541  0.715771   \n",
       "2       0       0 ...          0          0  0.171000  0.144830  0.449638   \n",
       "3       0       0 ...          0          0  0.175530  0.174649  0.607131   \n",
       "4       0       0 ...          0          0  0.209120  0.197158  0.449313   \n",
       "\n",
       "   windspeed       cnt  holiday  workingday  yr  \n",
       "0   0.284606  0.110792        0           0   0  \n",
       "1   0.466215  0.089623        0           0   0  \n",
       "2   0.465740  0.152669        0           1   0  \n",
       "3   0.284297  0.177174        0           1   0  \n",
       "4   0.339143  0.181546        0           1   0  \n",
       "\n",
       "[5 rows x 35 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_csv(\"FE_df.csv\")\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 731 entries, 0 to 730\n",
      "Data columns (total 35 columns):\n",
      "instant         731 non-null int64\n",
      "season_1        731 non-null int64\n",
      "season_2        731 non-null int64\n",
      "season_3        731 non-null int64\n",
      "season_4        731 non-null int64\n",
      "mnth_1          731 non-null int64\n",
      "mnth_2          731 non-null int64\n",
      "mnth_3          731 non-null int64\n",
      "mnth_4          731 non-null int64\n",
      "mnth_5          731 non-null int64\n",
      "mnth_6          731 non-null int64\n",
      "mnth_7          731 non-null int64\n",
      "mnth_8          731 non-null int64\n",
      "mnth_9          731 non-null int64\n",
      "mnth_10         731 non-null int64\n",
      "mnth_11         731 non-null int64\n",
      "mnth_12         731 non-null int64\n",
      "weathersit_1    731 non-null int64\n",
      "weathersit_2    731 non-null int64\n",
      "weathersit_3    731 non-null int64\n",
      "weekday_0       731 non-null int64\n",
      "weekday_1       731 non-null int64\n",
      "weekday_2       731 non-null int64\n",
      "weekday_3       731 non-null int64\n",
      "weekday_4       731 non-null int64\n",
      "weekday_5       731 non-null int64\n",
      "weekday_6       731 non-null int64\n",
      "temp            731 non-null float64\n",
      "atemp           731 non-null float64\n",
      "hum             731 non-null float64\n",
      "windspeed       731 non-null float64\n",
      "cnt             731 non-null float64\n",
      "holiday         731 non-null int64\n",
      "workingday      731 non-null int64\n",
      "yr              731 non-null int64\n",
      "dtypes: float64(5), int64(30)\n",
      "memory usage: 200.0 KB\n"
     ]
    }
   ],
   "source": [
    "df.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 从原始数据中分离出输入特征x和输出y\n",
    "y = df[\"cnt\"]\n",
    "X = df.drop([\"cnt\"], axis =1)\n",
    "\n",
    "#特征名称、用于后续显示权重系数对应的特征\n",
    "feat_names = X.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(584, 34)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#将数据分割成训练数据与测试数据\n",
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "#随机采样20%的数据构建测试样本，其余作为训练样本\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, random_state = 25, test_size = 0.2)\n",
    "X_train.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3.确定模型类型\n",
    "\n",
    "## 3.1 OLS线性回归"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>coef</th>\n",
       "      <th>columns</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>0.585398</td>\n",
       "      <td>yr</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>0.321323</td>\n",
       "      <td>temp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>0.141048</td>\n",
       "      <td>mnth_9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>0.124497</td>\n",
       "      <td>mnth_10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>0.111647</td>\n",
       "      <td>mnth_12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>0.099031</td>\n",
       "      <td>weathersit_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>0.094425</td>\n",
       "      <td>atemp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.083626</td>\n",
       "      <td>season_4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>0.073372</td>\n",
       "      <td>mnth_11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>0.043014</td>\n",
       "      <td>weathersit_2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>0.036256</td>\n",
       "      <td>weekday_6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>0.033332</td>\n",
       "      <td>mnth_8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>0.028878</td>\n",
       "      <td>workingday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.015275</td>\n",
       "      <td>season_3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.006097</td>\n",
       "      <td>season_2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>0.004006</td>\n",
       "      <td>weekday_5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>0.001844</td>\n",
       "      <td>weekday_3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>0.000716</td>\n",
       "      <td>weekday_4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>0.000177</td>\n",
       "      <td>mnth_6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-0.000954</td>\n",
       "      <td>instant</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>-0.004002</td>\n",
       "      <td>weekday_2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>-0.010130</td>\n",
       "      <td>mnth_5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>-0.017128</td>\n",
       "      <td>weekday_0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>-0.021692</td>\n",
       "      <td>weekday_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>-0.026305</td>\n",
       "      <td>mnth_7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>-0.048005</td>\n",
       "      <td>holiday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>-0.049807</td>\n",
       "      <td>mnth_4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>-0.071909</td>\n",
       "      <td>mnth_3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-0.104997</td>\n",
       "      <td>season_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>-0.142045</td>\n",
       "      <td>weathersit_3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>-0.143973</td>\n",
       "      <td>hum</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>-0.144159</td>\n",
       "      <td>mnth_2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>-0.155176</td>\n",
       "      <td>windspeed</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>-0.181764</td>\n",
       "      <td>mnth_1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        coef       columns\n",
       "33  0.585398            yr\n",
       "27  0.321323          temp\n",
       "13  0.141048        mnth_9\n",
       "14  0.124497       mnth_10\n",
       "16  0.111647       mnth_12\n",
       "17  0.099031  weathersit_1\n",
       "28  0.094425         atemp\n",
       "4   0.083626      season_4\n",
       "15  0.073372       mnth_11\n",
       "18  0.043014  weathersit_2\n",
       "26  0.036256     weekday_6\n",
       "12  0.033332        mnth_8\n",
       "32  0.028878    workingday\n",
       "3   0.015275      season_3\n",
       "2   0.006097      season_2\n",
       "25  0.004006     weekday_5\n",
       "23  0.001844     weekday_3\n",
       "24  0.000716     weekday_4\n",
       "10  0.000177        mnth_6\n",
       "0  -0.000954       instant\n",
       "22 -0.004002     weekday_2\n",
       "9  -0.010130        mnth_5\n",
       "20 -0.017128     weekday_0\n",
       "21 -0.021692     weekday_1\n",
       "11 -0.026305        mnth_7\n",
       "31 -0.048005       holiday\n",
       "8  -0.049807        mnth_4\n",
       "7  -0.071909        mnth_3\n",
       "1  -0.104997      season_1\n",
       "19 -0.142045  weathersit_3\n",
       "29 -0.143973           hum\n",
       "6  -0.144159        mnth_2\n",
       "30 -0.155176     windspeed\n",
       "5  -0.181764        mnth_1"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.linear_model import LinearRegression\n",
    "\n",
    "#使用默认配置初始化\n",
    "lr = LinearRegression()\n",
    "\n",
    "#用训练数据训练模型参数\n",
    "lr.fit(X_train, y_train)\n",
    "\n",
    "#用训练好的模型对测试集进行预测\n",
    "y_test_pred_lr = lr.predict(X_test)\n",
    "y_train_pred_lr = lr.predict(X_train)\n",
    "\n",
    "#看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(feat_names), \"coef\":list((lr.coef_))})\n",
    "fs.sort_values(by = [\"coef\"], ascending = False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3.1.1模型评价"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of LinearRegression on test is 0.8601215197621129\n",
      "The r2 score of LinearRegression on train is 0.8446090552070287\n"
     ]
    }
   ],
   "source": [
    "#使用r2_score评价模型在测试集合训练集上的性能，并输出评估结果\n",
    "#测试集\n",
    "print(\"The r2 score of LinearRegression on test is\", r2_score(y_test, y_test_pred_lr))\n",
    "#训练集\n",
    "print(\"The r2 score of LinearRegression on train is\", r2_score(y_train, y_train_pred_lr))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The RMSE of LinearRegression on test is 0.07946376409771734\n",
      "The RMSE of LinearRegression on train is 0.08870165958498726\n"
     ]
    }
   ],
   "source": [
    "# 使用RMSE评价模型在测试集和训练集上的性能，并输出评估结果\n",
    "RMSE_test_ols = mean_squared_error(y_test, y_test_pred_lr)**0.5\n",
    "print(\"The RMSE of LinearRegression on test is\",RMSE_test_ols)\n",
    "RMSE_train_ols = mean_squared_error(y_train, y_train_pred_lr)**0.5\n",
    "print(\"The RMSE of LinearRegression on train is\", RMSE_train_ols)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3.1.2可视化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0xbd10d68>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAekAAAFsCAYAAADos0H8AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAHbVJREFUeJzt3XuYXHWd5/H3l6QhDCGBQIKBOCYoINck2FwyCEQjwkyQsM+q6HAJSwQH1GV0vYCXMaLuyMDgyMLwmEUlCAyB7GBYXV2YCCIsgglGBIImIkhCTJool4AICd/9o05ik3Snq7uru37pfr+ep5+qc+rUOd9fVXd/+vc7p38VmYkkSSrPds0uQJIkdcyQliSpUIa0JEmFMqQlSSqUIS1JUqEMaUmSCmVIa9CLiIcjYmqz62imiPhPEfFkRKyLiMn9eNx1EbF3J4+dGRF3N+g4j0fEOxqxL6k/GdIa0Dr65bz5L//MPDAz7+xiP+MjIiNiaB+V2myXAh/OzOGZ+bPNH6za/kIVqisj4rKIGNLbg1bHe6y3+5EGKkNaKkAB4f8G4OEutpmYmcOBY4FTgLP6vCppkDOkNei1721HxOERsSginouI1RFxWbXZXdXtM1VvckpEbBcRn42IJyJiTURcGxEj2+33jOqxtRHxuc2OMzsi5kfEdRHxHHBmdex7I+KZiFgVEVdExPbt9pcRcV5ELIuI5yPiixHx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znrrLOYOnUqe++992vC+7rrruPwww9n0qRJfPCDH9wUvOeeey6tra0ceOCBm14DqE15fdFFF/HWt76Vm2++ua5a6uVwtyTpNTZs2MDChQuZNWsWALfddhvLli3j/vvvJzM56aSTuOuuu2hra2PPPffke9/7HgDPPvvsa/azatUqPv/5z7N48WJGjhzJ2972NiZPnrzVYw8bNoxbbrmFESNG8PTTT3PkkUdy0kknveYirBtuuIHjjz+ez3zmM2zYsIEXX3yxR+189NFHueOOO3j++efZb7/9OPfcc1m+fDnz5s3jnnvuoaWlhfPOO4/rr7+eM844gy9/+cuMGjWKDRs2MG3aNB588EEOOeSQTXXffffdPapjawxpSRIAf/zjH5k0aRKPP/44b3nLWzjuuOOAWkjfdtttmwJ23bp1LFu2jKOPPpqPf/zjfOpTn+LEE0/k6KOPfs3+7rvvPqZOncro0bUPfDrllFP41a9+tdUaMpNPf/rT3HXXXWy33XasXLmS1atX87rXvW7TNocddhhnnXUWr7zyCieffDKTJk3qUXunT5/ODjvswA477MCYMWNYvXo1CxcuZPHixRx22GGbXpMxY8YAcNNNNzFnzhzWr1/PqlWreOSRRzaF9CmnnNKjGrricLckCfjzOeknnniCl19+edM56czkwgsvZMmSJSxZsoTly5cza9Ys9t13XxYvXszBBx/MhRdeyEUXXbTFPjv7N6ShQ4fy6quvbtr/yy+/DMD1119PW1sbixcvZsmSJeyxxx5b/K/xMcccw1133cVee+3F6aefzrXXXtuj9u6www6b7g8ZMoT169eTmcycOXNTW3/5y18ye/ZsfvOb33DppZeycOFCHnzwQaZPn/6aunbaaace1dAVe9KSitOMK5v1ZyNHjuTyyy9nxowZnHvuuRx//PF87nOf49RTT2X48OGsXLmSlpYW1q9fz6hRozjttNMYPnw411xzzWv2c8QRR3D++eezdu1aRowYwc0338zEiROB2nncxYsX8973vpcFCxbwyiuvALUh8zFjxtDS0sIdd9zBE09s+amOTzzxBHvttRdnn302L7zwAg888ABnnHFGQ9o+bdo0ZsyYwUc/+lHGjBnD73//e55//nmee+45dtppJ0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ZGZqwCq2zGbbxAR2wH/DHyin2vriS7bAxARr4+IB4EngYurcCtRXe3ZKCIOB7YHft0PtfVUt9pUqL2ofe9stKJa1+E2mbkeeBbYrV+q67562rMt6W57ZgHf79OKeqeu9kTEhyLi19R60v+1n2prmN5MC7pNi4j/AF7XwUOfqXMX5wH/JzOfLKEj0ID2kJlPAodUw9zfiYj5mbm6UTV2RyPaU+1nLPBtYGZmNrW306g2FayeqYLrmk64ENtSrfWouz0RcRrQChzbpxX1Tr1TU18JXBkRfwt8FpjZ14U10qAN6cx8R2ePRcTqiBibmauqX/JrOthsCnB0RJwHDAe2j4h1mdmUz9VuQHva7+upiHgYOJrakGS/a0R7ImIE8D3gs5n5kz4qtW6NfI8KVc9UwRu3WRERQ4GRwO/7p7xuG2hTH9fVnoh4B7U/HI9tdwqsRN19f24ErurTivqAw90du5U//7U1E1iw+QaZeWpm/mVmjgc+DlzbrICuQ5ftiYhxEbFjdX9X4CjK/cSyetqzPXALtffl5n6srae6bNM2oJ6pgtu3893AD7PcGZUG2tTHXbYnIiYDXwdOyszS/1Cspz37tFucDizrx/oaIzP92uyL2jmyhdTe0IXAqGp9K3B1B9ufCVzR7Lp70x7gOOBB4OfV7TnNrruX7TkNeAVY0u5rUrNr7+33HPBjoA34I7WexPHNrn2zdvwN8Ctq5/8/U627iNovfYBhwM3AcuB+YO9m19zL9hxWvQ8vAGuBh5tdcy/b8x/A6nY/M7c2u+ZetudrwMNVW+4ADmx2zd39clpQSZIK5XC3JEmFMqQlSSqUIS1JUqEMaUmSCmVIS5JUKENakqRCGdKSJBXq/wOJITgvTO/scwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x58f0b38>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#观察预测残差的分布\n",
    "f, ax = plt.subplots(figsize = (7, 5))\n",
    "f.tight_layout()\n",
    "ax.hist(y_train - y_train_pred_lr, bins = 40, label = \"Residuals Linear\", color = \"b\", alpha = .5)\n",
    "ax.set_title(\"Histogram of Residuals\")\n",
    "ax.legend(loc = \"best\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "残差分布和高斯分布比较匹配"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARgAAADQCAYAAADcQn7hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJztnXl4VdXVuN+V5BISpgRIEaMITjigEkkVBScEAQekVgWqrbaKn1atdKDFtl+1SAWlv6r9VVvROtuCOKRQaXEAS6VFwQZFLTPWEkDCEBAIGdf3xzkXb5I7nOSek5thvc9zn5y7h7PXSXLX3XvtvdYSVcUwDCMI0lItgGEYbRdTMIZhBIYpGMMwAsMUjGEYgWEKxjCMwDAFYxhGYJiCMQwjMEzBGIYRGKZgDMMIjIxUC9Cc9OzZU/v27ZtqMQyj1fPee+/tUNW8RO3alYLp27cvK1asSLUYhtHqEZH/eGlnSyTDMALDFIxhGIGRUgUjIk+IyHYR+TBGvYjIr0VkvYh8ICKnR9RdJyLr3Nd1zSe1YRheSfUM5ilgVJz60cBx7usm4LcAItIduAs4EzgDuEtEcgOV1DCMRpNSBaOqS4BdcZpcDjyjDsuAHBHpDYwEXlfVXaq6G3id+IrKMIwYVFZW8uGHURcRSZPqGUwi8oH/Rrzf7JbFKm+AiNwkIitEZEVpaWlgghpGa6W4uJgLL7yQsrIy3+/d0hWMRCnTOOUNC1VnqWqhqhbm5SXctjeMdsPGjRsBOPPMM1myZAk5OTm+j9HSFcxm4MiI90cAW+KUG4aRgJqaGu666y6OP/54Fi1aBED//v0DGaulK5h5wDfc3aTBwB5V3QosBC4SkVzXuHuRW2YYR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YpGMMwAsMUjGEYgWEKxjCMwDAFY3hCRHpEePRuE5GSiPeN8ib3Wa7hIlKUqvGN+LTZk7yGv6hz0nUggIjcjePh+8vINq5jpOgXLg1GO8dmMEZSiMixIvKhiPwO+BdwZL1YJuPFzTcuIr1E5GXXce9dERkc5X4rRKR/xPu3ReQ0ERksTnycYhFZKiLHRek7TUQmRbxfLSJHuNfXuWOuFJFHRMT+95sB+yUbfnAS8HtVLQBK4rT7NY5bRCFwNfB4lDZz3Dpc5dBDVd8H/g0Mdce4B5jmVTgRGYBz/P9sVR2IM3Mf77W/0XRsiWT4wQZVXe6h3XCgv7OSAiBXRLJUtTyizQs4ns33AOPc9wA5wDMickwT5BsOfBlY4Y6dRd0wBEZAmIIx/GB/xHUtdd38O0ZcC3CGOkGXoqKq/xGRfSJyEo6Cud6t+gWwUFUfEZFjgb9G6V5N3Vl5eGzBiRD3v14exvAPWyIZvuIaeHeLyHGuneMrEdVvEBGKQGLHEp6DE/MmU1U/dsu68cXy6/oY/T4BBrn3PoMvQhC8AVwtIj3duh4i0qcRj2U0EVMwRhD8CGeG8SaO926YW4EhbtS4j4GJMfrPBb7GF8sjcOKzzBSRpXHGnQv0EpFiHI/hjQCqugr4OfCGiHwAvAb0avRTGY3GvKkNwwgMm8EYhhEYpmAMwwgMUzCGYQSGKRjDMALDFIxhGIFhCsYwjMAwBWMYRmD8H2yPEOkA7uNYAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xc2b52b0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#观察预测值和真值的散点图\n",
    "plt.figure(figsize = (4,3))\n",
    "plt.scatter(y_train, y_train_pred_lr)\n",
    "plt.plot([-0.5, 1], [-0.5,1],'--k')\n",
    "plt.axis(\"tight\")#展示所有数据\n",
    "plt.xlabel(\"True value\")\n",
    "plt.ylabel(\"Predicted value\")\n",
    "plt.tight_layout()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3.2正则化的线性回归（L2正则--岭回归）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of RidgeCV on test is 0.8616929255034618\n",
      "The r2 score of RidgeCV on train is 0.8442595173516665\n",
      "The RMSE of RidgeCV on test is 0.07901615236337806\n",
      "The RMSE of RidgeCV on train is 0.0888013667203642\n"
     ]
    }
   ],
   "source": [
    "#岭回归/L2正则\n",
    "from sklearn.linear_model import RidgeCV\n",
    "\n",
    "#1.设置超参数范围\n",
    "alphas = [0.01, 0.1, 1, 10, 100]  \n",
    "\n",
    "#2.生成一个RidgeCV实例\n",
    "ridge = RidgeCV(alphas = alphas, store_cv_values = True)\n",
    "\n",
    "#3.模型训练\n",
    "ridge.fit(X_train, y_train)\n",
    "\n",
    "#4.预测\n",
    "y_test_pred_ridge = ridge.predict(X_test)\n",
    "y_train_pred_ridge = ridge.predict(X_train)\n",
    "\n",
    "#5.r2评估\n",
    "print(\"The r2 score of RidgeCV on test is\", r2_score(y_test, y_test_pred_ridge))\n",
    "print(\"The r2 score of RidgeCV on train is\", r2_score(y_train, y_train_pred_ridge))\n",
    "\n",
    "#6.RMSE评估\n",
    "RMSE_test_ridge = mean_squared_error(y_test, y_test_pred_ridge)**0.5\n",
    "RMSE_train_ridge = mean_squared_error(y_train, y_train_pred_ridge)**0.5\n",
    "print(\"The RMSE of RidgeCV on test is\", RMSE_test_ridge)\n",
    "print(\"The RMSE of RidgeCV on train is\", RMSE_train_ridge)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 可视化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZIAAAEKCAYAAAA4t9PUAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U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>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 0.1\n"
     ]
    }
   ],
   "source": [
    "mse_mean = np.mean(ridge.cv_values_, axis = 0)\n",
    "plt.plot(np.log10(alphas), mse_mean.reshape(len(alphas),1))\n",
    "plt.xlabel(\"log(alpha)\")\n",
    "plt.ylabel(\"mse\")\n",
    "plt.show()\n",
    "print(\"alpha is:\", ridge.alpha_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>coef_lr</th>\n",
       "      <th>coef_ridge</th>\n",
       "      <th>columns</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>0.585398</td>\n",
       "      <td>0.411731</td>\n",
       "      <td>yr</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>0.321323</td>\n",
       "      <td>0.277313</td>\n",
       "      <td>temp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>0.141048</td>\n",
       "      <td>0.105815</td>\n",
       "      <td>mnth_9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>0.124497</td>\n",
       "      <td>0.072379</td>\n",
       "      <td>mnth_10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>0.111647</td>\n",
       "      <td>0.029076</td>\n",
       "      <td>mnth_12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>0.099031</td>\n",
       "      <td>0.098489</td>\n",
       "      <td>weathersit_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>0.094425</td>\n",
       "      <td>0.131939</td>\n",
       "      <td>atemp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.083626</td>\n",
       "      <td>0.084864</td>\n",
       "      <td>season_4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>0.073372</td>\n",
       "      <td>0.005164</td>\n",
       "      <td>mnth_11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>0.043014</td>\n",
       "      <td>0.042798</td>\n",
       "      <td>weathersit_2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>0.036256</td>\n",
       "      <td>0.035906</td>\n",
       "      <td>weekday_6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>0.033332</td>\n",
       "      <td>0.015335</td>\n",
       "      <td>mnth_8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>0.028878</td>\n",
       "      <td>0.028810</td>\n",
       "      <td>workingday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.015275</td>\n",
       "      <td>0.015303</td>\n",
       "      <td>season_3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.006097</td>\n",
       "      <td>0.005200</td>\n",
       "      <td>season_2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>0.004006</td>\n",
       "      <td>0.004205</td>\n",
       "      <td>weekday_5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>0.001844</td>\n",
       "      <td>0.002320</td>\n",
       "      <td>weekday_3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>0.000716</td>\n",
       "      <td>0.000864</td>\n",
       "      <td>weekday_4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>0.000177</td>\n",
       "      <td>0.010167</td>\n",
       "      <td>mnth_6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-0.000954</td>\n",
       "      <td>-0.000480</td>\n",
       "      <td>instant</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>-0.004002</td>\n",
       "      <td>-0.004000</td>\n",
       "      <td>weekday_2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>-0.010130</td>\n",
       "      <td>0.013530</td>\n",
       "      <td>mnth_5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>-0.017128</td>\n",
       "      <td>-0.017515</td>\n",
       "      <td>weekday_0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>-0.021692</td>\n",
       "      <td>-0.021781</td>\n",
       "      <td>weekday_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>-0.026305</td>\n",
       "      <td>-0.030649</td>\n",
       "      <td>mnth_7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>-0.048005</td>\n",
       "      <td>-0.047201</td>\n",
       "      <td>holiday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>-0.049807</td>\n",
       "      <td>-0.013018</td>\n",
       "      <td>mnth_4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>-0.071909</td>\n",
       "      <td>-0.022167</td>\n",
       "      <td>mnth_3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-0.104997</td>\n",
       "      <td>-0.105367</td>\n",
       "      <td>season_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>-0.142045</td>\n",
       "      <td>-0.141288</td>\n",
       "      <td>weathersit_3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>-0.143973</td>\n",
       "      <td>-0.145474</td>\n",
       "      <td>hum</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>-0.144159</td>\n",
       "      <td>-0.080603</td>\n",
       "      <td>mnth_2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>-0.155176</td>\n",
       "      <td>-0.155129</td>\n",
       "      <td>windspeed</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>-0.181764</td>\n",
       "      <td>-0.105028</td>\n",
       "      <td>mnth_1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     coef_lr  coef_ridge       columns\n",
       "33  0.585398    0.411731            yr\n",
       "27  0.321323    0.277313          temp\n",
       "13  0.141048    0.105815        mnth_9\n",
       "14  0.124497    0.072379       mnth_10\n",
       "16  0.111647    0.029076       mnth_12\n",
       "17  0.099031    0.098489  weathersit_1\n",
       "28  0.094425    0.131939         atemp\n",
       "4   0.083626    0.084864      season_4\n",
       "15  0.073372    0.005164       mnth_11\n",
       "18  0.043014    0.042798  weathersit_2\n",
       "26  0.036256    0.035906     weekday_6\n",
       "12  0.033332    0.015335        mnth_8\n",
       "32  0.028878    0.028810    workingday\n",
       "3   0.015275    0.015303      season_3\n",
       "2   0.006097    0.005200      season_2\n",
       "25  0.004006    0.004205     weekday_5\n",
       "23  0.001844    0.002320     weekday_3\n",
       "24  0.000716    0.000864     weekday_4\n",
       "10  0.000177    0.010167        mnth_6\n",
       "0  -0.000954   -0.000480       instant\n",
       "22 -0.004002   -0.004000     weekday_2\n",
       "9  -0.010130    0.013530        mnth_5\n",
       "20 -0.017128   -0.017515     weekday_0\n",
       "21 -0.021692   -0.021781     weekday_1\n",
       "11 -0.026305   -0.030649        mnth_7\n",
       "31 -0.048005   -0.047201       holiday\n",
       "8  -0.049807   -0.013018        mnth_4\n",
       "7  -0.071909   -0.022167        mnth_3\n",
       "1  -0.104997   -0.105367      season_1\n",
       "19 -0.142045   -0.141288  weathersit_3\n",
       "29 -0.143973   -0.145474           hum\n",
       "6  -0.144159   -0.080603        mnth_2\n",
       "30 -0.155176   -0.155129     windspeed\n",
       "5  -0.181764   -0.105028        mnth_1"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#看看各特征的权重系数， 系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(feat_names), \"coef_lr\":list((lr.coef_)), \"coef_ridge\":list((ridge.coef_))})\n",
    "fs.sort_values(by = [\"coef_lr\"], ascending = False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3.3正则化的线性回归（L1正则--Lasso）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of LassoCV on test is 0.5299616287923182\n",
      "The r2 score of LassoCV on train is 0.45038380663065036\n",
      "The RMSE of LassoCV on test is 0.14566671855928584\n",
      "The RMSE of LassoCV on train is 0.16682020546448167\n"
     ]
    }
   ],
   "source": [
    "#Lasso/L1正则\n",
    "from sklearn.linear_model import LassoCV\n",
    "\n",
    "#1.设置超参数搜索范围\n",
    "#alphas = [0.01, 0.1, 1, 10, 100]\n",
    "\n",
    "#2.生成学习器实例\n",
    "lasso = LassoCV()\n",
    "\n",
    "#3.训练\n",
    "lasso.fit(X_train, y_train)\n",
    "\n",
    "#4.测试\n",
    "y_test_pred_lasso = lasso.predict(X_test)\n",
    "y_train_pred_lasso = lasso.predict(X_train)\n",
    "\n",
    "#5.r2评估\n",
    "print(\"The r2 score of LassoCV on test is\", r2_score(y_test, y_test_pred_lasso))\n",
    "print(\"The r2 score of LassoCV on train is\", r2_score(y_train, y_train_pred_lasso))\n",
    "\n",
    "#6.RMSE评估\n",
    "RMSE_test_lasso = mean_squared_error(y_test, y_test_pred_lasso)**0.5\n",
    "RMSE_train_lasso = mean_squared_error(y_train, y_train_pred_lasso)**0.5\n",
    "print(\"The RMSE of LassoCV on test is\", RMSE_test_lasso)\n",
    "print(\"The RMSE of LassoCV on train is\", RMSE_train_lasso)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 可视化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZIAAAEKCAYAAAA4t9PUAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3Xl4XPV97/H3V7uRZRtbMnhFNjZgAzYhwiRsCUspZDMQCJAuJKWlJCFN2ie3cZr7hITe21ySp5fbNiQNDdyQhaVlSUzKFkKoS26QkTHGFjZGljfJsiVbtjZby8x87x9zRAdFy1iznBnp83oePXPmnN/5ne9PsvXRWeYcc3dERETGqyDsAkREJL8pSEREJCUKEhERSYmCREREUqIgERGRlChIREQkJQoSERFJiYJERERSoiAREZGUFIVdQDZUVlZ6dXV12GWIiOSNDRs2HHT3qmTaToogqa6upq6uLuwyRETyhpntTratDm2JiEhKFCQiIpISBYmIiKREQSIiIilRkIiISEoUJCIikpKMBomZXWVmb5lZg5mtGWZ5qZk9GiyvNbPqY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Qm9C+LKhBJKN0aEskOeuAG82sMDhvcQnxGyq+TPzBTQVmdhLxx5gO2gosCaanAT1AR9Du6hG2U0D8jr8Anwz6H810oCXYI/oj4o+/HXQa+Xsnaskj2iMRSc6TxM9/bCK+l/DX7r7fzB4HLif+C3s7UEv8iYYA/048WF5w901mtpH4XVcbgd+MsJ0e4Ewz2xD0c+MYdX0XeNzMbiB+d92ehGWXBjWIZJTu/iuSIjOb6vGnzc0ivpdyYRAyU4j/cr8wOLeSTF/d7j41TXWtA1a7++F09CcyEu2RiKTuF2Y2AygB/tbd9wO4+zEzu5P4s733ZLOg4PDb/1aISDZoj0RERFKik+0iIpISBYmIiKREQSIiIilRkIiISEoUJCIikhIFiYiIpOT/A4ZO+YOB/Ek7AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xb48e438>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 0.029074549563508332\n"
     ]
    }
   ],
   "source": [
    "mses = np.mean(lasso.mse_path_, axis = 1)\n",
    "plt.plot(np.log10(lasso.alphas_), mses)\n",
    "plt.xlabel(\"log(alpha)\")\n",
    "plt.ylabel(\"mse\")\n",
    "plt.show()\n",
    "\n",
    "print(\"alpha is:\", lasso.alpha_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>coef_lasso</th>\n",
       "      <th>coef_lr</th>\n",
       "      <th>coef_ridge</th>\n",
       "      <th>columns</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.585398</td>\n",
       "      <td>0.411731</td>\n",
       "      <td>yr</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.321323</td>\n",
       "      <td>0.277313</td>\n",
       "      <td>temp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.141048</td>\n",
       "      <td>0.105815</td>\n",
       "      <td>mnth_9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.124497</td>\n",
       "      <td>0.072379</td>\n",
       "      <td>mnth_10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>0.111647</td>\n",
       "      <td>0.029076</td>\n",
       "      <td>mnth_12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.099031</td>\n",
       "      <td>0.098489</td>\n",
       "      <td>weathersit_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.094425</td>\n",
       "      <td>0.131939</td>\n",
       "      <td>atemp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>0.083626</td>\n",
       "      <td>0.084864</td>\n",
       "      <td>season_4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>0.073372</td>\n",
       "      <td>0.005164</td>\n",
       "      <td>mnth_11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>0.043014</td>\n",
       "      <td>0.042798</td>\n",
       "      <td>weathersit_2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>0.036256</td>\n",
       "      <td>0.035906</td>\n",
       "      <td>weekday_6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.033332</td>\n",
       "      <td>0.015335</td>\n",
       "      <td>mnth_8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.028878</td>\n",
       "      <td>0.028810</td>\n",
       "      <td>workingday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.015275</td>\n",
       "      <td>0.015303</td>\n",
       "      <td>season_3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.006097</td>\n",
       "      <td>0.005200</td>\n",
       "      <td>season_2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.004006</td>\n",
       "      <td>0.004205</td>\n",
       "      <td>weekday_5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.001844</td>\n",
       "      <td>0.002320</td>\n",
       "      <td>weekday_3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000716</td>\n",
       "      <td>0.000864</td>\n",
       "      <td>weekday_4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000177</td>\n",
       "      <td>0.010167</td>\n",
       "      <td>mnth_6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.000627</td>\n",
       "      <td>-0.000954</td>\n",
       "      <td>-0.000480</td>\n",
       "      <td>instant</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.004002</td>\n",
       "      <td>-0.004000</td>\n",
       "      <td>weekday_2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.010130</td>\n",
       "      <td>0.013530</td>\n",
       "      <td>mnth_5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>-0.017128</td>\n",
       "      <td>-0.017515</td>\n",
       "      <td>weekday_0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>-0.021692</td>\n",
       "      <td>-0.021781</td>\n",
       "      <td>weekday_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.026305</td>\n",
       "      <td>-0.030649</td>\n",
       "      <td>mnth_7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>-0.048005</td>\n",
       "      <td>-0.047201</td>\n",
       "      <td>holiday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.049807</td>\n",
       "      <td>-0.013018</td>\n",
       "      <td>mnth_4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>-0.071909</td>\n",
       "      <td>-0.022167</td>\n",
       "      <td>mnth_3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-0.054092</td>\n",
       "      <td>-0.104997</td>\n",
       "      <td>-0.105367</td>\n",
       "      <td>season_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>-0.142045</td>\n",
       "      <td>-0.141288</td>\n",
       "      <td>weathersit_3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>-0.143973</td>\n",
       "      <td>-0.145474</td>\n",
       "      <td>hum</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>-0.144159</td>\n",
       "      <td>-0.080603</td>\n",
       "      <td>mnth_2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>-0.155176</td>\n",
       "      <td>-0.155129</td>\n",
       "      <td>windspeed</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>-0.181764</td>\n",
       "      <td>-0.105028</td>\n",
       "      <td>mnth_1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    coef_lasso   coef_lr  coef_ridge       columns\n",
       "33    0.000000  0.585398    0.411731            yr\n",
       "27    0.000000  0.321323    0.277313          temp\n",
       "13    0.000000  0.141048    0.105815        mnth_9\n",
       "14    0.000000  0.124497    0.072379       mnth_10\n",
       "16   -0.000000  0.111647    0.029076       mnth_12\n",
       "17    0.000000  0.099031    0.098489  weathersit_1\n",
       "28    0.000000  0.094425    0.131939         atemp\n",
       "4    -0.000000  0.083626    0.084864      season_4\n",
       "15   -0.000000  0.073372    0.005164       mnth_11\n",
       "18   -0.000000  0.043014    0.042798  weathersit_2\n",
       "26   -0.000000  0.036256    0.035906     weekday_6\n",
       "12    0.000000  0.033332    0.015335        mnth_8\n",
       "32    0.000000  0.028878    0.028810    workingday\n",
       "3     0.000000  0.015275    0.015303      season_3\n",
       "2     0.000000  0.006097    0.005200      season_2\n",
       "25    0.000000  0.004006    0.004205     weekday_5\n",
       "23    0.000000  0.001844    0.002320     weekday_3\n",
       "24    0.000000  0.000716    0.000864     weekday_4\n",
       "10    0.000000  0.000177    0.010167        mnth_6\n",
       "0     0.000627 -0.000954   -0.000480       instant\n",
       "22    0.000000 -0.004002   -0.004000     weekday_2\n",
       "9     0.000000 -0.010130    0.013530        mnth_5\n",
       "20   -0.000000 -0.017128   -0.017515     weekday_0\n",
       "21   -0.000000 -0.021692   -0.021781     weekday_1\n",
       "11    0.000000 -0.026305   -0.030649        mnth_7\n",
       "31   -0.000000 -0.048005   -0.047201       holiday\n",
       "8     0.000000 -0.049807   -0.013018        mnth_4\n",
       "7    -0.000000 -0.071909   -0.022167        mnth_3\n",
       "1    -0.054092 -0.104997   -0.105367      season_1\n",
       "19   -0.000000 -0.142045   -0.141288  weathersit_3\n",
       "29   -0.000000 -0.143973   -0.145474           hum\n",
       "6    -0.000000 -0.144159   -0.080603        mnth_2\n",
       "30   -0.000000 -0.155176   -0.155129     windspeed\n",
       "5    -0.000000 -0.181764   -0.105028        mnth_1"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 看\"看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(feat_names), \"coef_lr\":list((lr.coef_)), \"coef_ridge\":list((ridge.coef_)), \"coef_lasso\":list((lasso.coef_))})\n",
    "fs.sort_values(by = [\"coef_lr\"],ascending = False)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
